package treeMap;



import java.util.TreeMap;

public class TreeMapTest {
    public static void main(String[] args) {

        // 创建TreeMap集合对象
        TreeMap<Student,String>tm=new TreeMap<>();

        Student s1=new Student("hanser",12);
        Student s2=new Student("田想",12);
        Student s3=new Student("谢慧",22);

        // 将学生对象添加到TreeMap集合中
        tm.put(s1,"江苏");
        tm.put(s2,"北京");
        tm.put(s3,"天津");


        // 遍历TreeMap集合,打印每个学生的信息
        tm.forEach(
                (Student key, String value)->{
                    System.out.println(key + "---" + value);
                }
        );
    }
}
